<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /*
          根据所赋的值判断是否允许赋值
        */
       const target = {
        onlyNumbersGoHere: 0
       }

       const proxy = new Proxy(target, {
        set(target, proterty, value) {
            if (typeof value !== 'number') {
                return false
            } else {
                return Reflect.set(...arguments)
            }
        }
       })
       proxy.onlyNumbersGoHere = 1
       console.log(proxy.onlyNumbersGoHere) // 1
       proxy.onlyNumbersGoHere = '2'
       console.log(proxy.onlyNumbersGoHere) // 1
    </script>
</body>
</html>